package JavaConcurrentMei.一;

public class ThreadLocalTest {

    static void print(String str) {
        System.out.println(str + ":" + localVaiables.get());
        localVaiables.remove();
    }

    static ThreadLocal<String> localVaiables = new ThreadLocal<>();

    public static void main(String[] args) {
        new Thread(() -> {
            localVaiables.set("t1 thread local");
            print("t1");
            System.out.println("t1 remove after: " + localVaiables.get());
        }, "t1").start();

        new Thread(() -> {
            localVaiables.set("t2 thread local");
            print("t2");
            System.out.println("t2 remove after: " + localVaiables.get());
        }, "t1").start();
    }
}
